package com.pagepub.expo.action;

import com.opensymphony.xwork2.ActionSupport;
import com.pagepub.expo.entity.AppRole;
import com.pagepub.expo.manager.AppRoleMng;

public class LoginAction extends ActionSupport {
	private AppRoleMng roleMng;
	public AppRoleMng getRoleMng() {
		return roleMng;
	}

	public void setRoleMng(AppRoleMng roleMng) {
		this.roleMng = roleMng;
	}

	public String login() throws Exception {

        if (isInvalid(getUsername())) return INPUT;

        if (isInvalid(getPassword())) return INPUT;
        if(roleMng==null){
        	System.out.println("mng null");
        }
       
        AppRole role =null;//roleMng.load(1);
        if(role!=null && role.getRoleName().endsWith("经理")){
       	return SUCCESS;
        }else
        	return "error";
    }

    private boolean isInvalid(String value) {
        return (value == null || value.length() == 0);
    }

    private String username;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    private String password;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
	

}
